home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / dfÜ / bbs / aptbbs1 / apt / rexx / mci2aml.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-10-10  |  3.2 KB  |  128 lines

  1. /* MCI2AML.rexx
  2. **
  3. ** $VER: MCI2AML 0.0.1 (26.4.93)
  4. **
  5. ** ARexx program for controlling ApT-BBS by ApT-Design.
  6. **
  7. ** Copyright © 1993 ApT-Design All Rights Reserved,TS
  8. **
  9. ** This script will take in a text file with MCI codes and
  10. ** copy the file to a new one, altering the control codes on
  11. ** the way to their AML equivelents.
  12. **
  13. */
  14.  
  15. /*
  16.  
  17. - stuff to convert -
  18.  
  19. %TC=<colour>.            TEXT COLOUR
  20. %BC=<colour>.            BACKGROUND COLOUR
  21. %CLS.                Clear Screen
  22. %ANSIRESET.            Reset ansi emulation via ESQ[0m
  23. %CURSOR=<0/1>.            Turn cursor off/on
  24. %CURSOR_LEFT=<positions>.    Postion cursor X positions to left.
  25. %CURSOR_RIGHT=<position>.    Position cursor X positions to right.
  26. %CURSOR_UP=<position>.        Position cursor X positions up.
  27. %CURSOR_DOWN=<position>.    Position cursor X positions down.
  28. %UNDERLINE=<0/1>.        Turn Underline Mode off/on.
  29. %RVIDEO=<0/1>.            Turn Reverse Video off/on.
  30. %BOLD=<0/1>.            Turn Bold off/on.
  31. %ITALICS=<0/1>            Turn Italics off/on.
  32. %WAITKEY.            Wait for a keypress.
  33.  
  34.  
  35. Allow room for other things such as:-
  36.  
  37. %CREDITS+1.
  38. %CREDITS/20.
  39. %CREDITS=213021.
  40.  
  41. Ahm, and here is the actual table then:-
  42.  
  43. \c{0-7}            =>        %TC={0-7}.
  44. \z{0-7}            =>        %BC={0-7}.
  45. \@            =>        %CLS.
  46. \z0\c7 or \c7\z0    =>        %ANSIRESET./*Not sure so not implmtd*/
  47. \o0            =>        %CURSOR=0.
  48. \o1            =>        %CURSOR=1.
  49. \<{0-9}            =>        %CURSOR_LEFT={0-9}.
  50. \>{0-9}            =>        %CURSOR_RIGHT={0-9}.
  51. \^{0-9}            =>        %CURSOR_UP={0-9}.
  52. \!{0-9}            =>        %CURSOR_DOWN={0-9}.
  53. \u0            =>        %UNDERLINE=0.
  54. \u1            =>        %UNDERLINE=1.
  55. \b0            =>        %BOLD=0.
  56. \b1            =>        %BOLD=1.
  57. \i0            =>        %ITALICS=0.
  58. \i1            =>        %ITALICS=1.
  59. \g{anything}        =>        %WAITKEY.
  60.  
  61. */
  62.  
  63. MCI.1 = 'C'        ;    AML.1 = 'TC'
  64. MCI.2 = 'Z'        ;    AML.2 = 'BC'
  65. MCI.3 = 'O'        ;    AML.3 = 'CURSOR'
  66. MCI.4 = '<'        ;    AML.4 = 'CURSOR_LEFT'
  67. MCI.5 = '>'        ;    AML.5 = 'CURSOR_RIGHT'
  68. MCI.6 = '^'        ;    AML.6 = 'CURSOR_UP'
  69. MCI.7 = '!'        ;    AML.7 = 'CURSOR_DOWN'
  70. MCI.8 = 'U'        ;    AML.8 = 'UNDERLINE'
  71. MCI.9 = 'B'        ;    AML.9 = 'BOLD'
  72. MCI.10= 'I'        ;    AML.10= 'ITALICS'
  73. MCI.11= 'G'        ;    AML.11= 'WAITKEY'
  74. MCI.12= '@'        ;    AML.12= 'CLS'
  75.  
  76. parse upper arg infile outfile .
  77. if ~open('in',infile,'R') then DO
  78.     say 'Cannot open MCI source file!'
  79.     EXIT
  80. END
  81. if ~open('out',outfile,'W') then DO
  82.     say 'Cannot open AML output file!'
  83.     EXIT
  84. END
  85.  
  86. DO while ~eof('in')
  87.     curline = readln('in')
  88.     newline = ''
  89.     DO charnum=1 to length(curline)
  90.                 curchar=substr(curline,charnum,1)
  91.         if curchar = '\' then DO
  92.             charnum=charnum+1
  93.                     curchar=substr(curline,charnum,1)
  94.             DO tst=1 to 12
  95.                 if upper(curchar) = upper(mci.tst) then DO
  96.                     supplement=''
  97.                     if tst ~>10 then supplement=supplement||substr(curline,charnum+1,1)
  98.                     call swapcode(tst,supplement)
  99.                     newcode=result
  100.                     if tst=11 then charnum=charnum+1
  101.                     charnum=charnum+length(supplement)
  102.                     newline=newline||newcode
  103.                 END
  104.             END
  105.         END
  106.         ELSE newline=newline||curchar
  107.     END
  108.     call writeln('out',newline)
  109. END
  110.  
  111. say 'Reached end!'
  112. EXIT
  113.  
  114.  
  115. /*****************************************************
  116.  * swapcode: Just gets the number of the MCI stem    *
  117.  *           and turns it into a similar AML thingy. *
  118.  *****************************************************/
  119.  
  120. swapcode:
  121. parse upper arg mcicode,magntd
  122.  
  123. if mcicode ~> 10 then return '%'||AML.mcicode||'='||magntd||'.'
  124. return '%'||AML.mcicode||'.'
  125.  
  126. /*Uhm............. well.. */
  127. RETURN /* indeedy! */
  128.